<template>
  <div class="app-container">
     <!-- <div class="detail-title">自定义方法模块</div> -->
    <el-row>
      <el-col :span="12">
        <div class="detail-title-form">
          <el-form ref="elform" :model="form" label-width="100px" :rules="elrules">
            <el-form-item label="模块分类：" prop="dlltype">
              <el-select v-model="form.dlltype" placeholder="请选择模块分类" @change="handleChange">
                <el-option :label="item.label" :value="item.value" v-for="item in moduleClassSelectList"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span="12">
        <el-button type="primary" class="detail-center-btn" @click="count(form)">
          <svg-icon icon-class="line-bar"/>
          计算
        </el-button>
      </el-col>
    </el-row>
    <div class="container">
      <div class="container-warp container-left" style="height: 285px;padding: 5px 10px 0;">
        <div class="table-title">材料性能</div>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="material-pic">
              <img src="@/assets/images/custom.jpg">
            </div>
          </el-col>
          <el-col :span="16" class="material-form">
            <el-form ref="mform" :model="form" label-width="80px" :inline="true" label-position="left" :rules="mrules">
              <el-form-item prop="materialtype">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="材料类别" placement="top" effect="light">
                      <div>
                        材料
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-select v-model="form.materialtype" placeholder="">
                  <el-option :label="item.label" :value="item.value" v-for="item in IMSelectList"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item  prop="rm">
                <template solt="label" >
                  <div class="label-subscript">
                    <el-tooltip content="材料标准试样的抗拉强度，MPa" placement="top" effect="light">
                      <div>
                        Rm（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.rm" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item prop="m1">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="P-S-N第一段折线斜率负倒数" placement="top" effect="light">
                      <div>
                        <sup>m<sub>1</sub></sup>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.m1" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item prop="m2">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="P-S-N第二段折线斜率负倒数" placement="top" effect="light">
                      <div>
                        <sup>m<sub>2</sub></sup>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.m2" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item  prop="nc">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="特征疲劳寿命 Cycle" placement="top" effect="light">
                      <div>
                        <sup>N<sub>c</sub></sup>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.nc" placeholder=""  type="number"></el-input>
              </el-form-item>
              <el-form-item  prop="nd">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="两折线段拐点对应疲劳寿命 Cycle" placement="top" effect="light">
                      <div>
                        <sup>N<sub>D</sub></sup>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.nd" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item prop="sc">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="应力比为-1的特征疲劳寿命对应疲劳强度幅值MPa" placement="top" effect="light">
                      <div v-if = "form.dlltype == 'PRETNWDLL' || form.dlltype == 'PRETWDLL'">
                        <sup>τ<sub>c</sub></sup>（>0）
                      </div>
                      <div v-else >
                        <sup>σ<sub>c</sub></sup>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.sc" placeholder="" type="number"></el-input>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
      </div>
      <div class="container-right">
        <div class="container-warp" style="height: 130px; padding: 5px 10px;">
          <div class="table-title">结构参数</div>
          <div class="structure-form">
            <el-form ref="jform" :model="form" label-width="60px" :inline="true" label-position="left"  :rules="jrules">
              <el-form-item label=""  prop="ktd">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="温度系数" placement="top" effect="light">
                      <div>
                        K<sub>TD</sub>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.ktd" placeholder="" type="number">
                  <el-button slot="append" @click="showWdModel">
                    <svg-icon icon-class="calculator"/>
                  </el-button>
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="kwk">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="设计系数" placement="top" effect="light">
                      <div>
                        K<sub>WK</sub>（>0）
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.kwk" placeholder="" type="number">
                  <el-button slot="append"  @click="showKwkModel">
                    <svg-icon icon-class="calculator"/>
                  </el-button>
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="dadmi"  v-if="form.ascm != 5 && form.ascm != '5'">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="损伤设计值" placement="top" effect="light">
                      <div>
                        D<sub>admi</sub>
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.dadmi" placeholder=""  type="number">
                  <!-- <el-button slot="append"  @click="countDadmi(form)">
                    <svg-icon icon-class="calculator"/>
                  </el-button> -->
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="C" v-if="form.ascm == 5 || form.ascm == '5' ">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="损伤设计值" placement="top" effect="light">
                      <div>
                        C
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.c" placeholder=""  type="number" oninput="value=value.replace(/[^0-9]/g,'')">
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="N" v-if="form.ascm == 5 || form.ascm == '5' ">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="载荷谱年限" placement="top" effect="light">
                      <div>
                        N
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.n" placeholder=""  type="number"  oninput="value=value.replace(/[^0-9]/g,'')">
                </el-input>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="container-warp" style="height: 145px; padding: 5px 10px;">
          <div class="table-title">服役载荷</div>
          <div class="structure-forms">
            <el-form ref="fform" :model="form" label-width="125px" :inline="true" label-position="left" :rules="frules">
              <el-form-item label="平均应力修正方法"  prop="ascm">
                <el-select v-model="form.ascm" placeholder="">
                  <el-option :label="item.label" :value="item.value"
                             v-for="item in correctionMethodSelectList"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item v-if="form.dlltype == 'PRESWDLL' || form.dlltype == 'PRETWDLL' " label="残余应力类型"  prop="rst">
                <el-select v-model="form.rst" placeholder="">
                  <el-option :label="item.label" :value="item.value" v-for="item in SMINSelectList"></el-option>
                </el-select>
              </el-form-item>
              <!-- <el-form-item label="" class="form-label-tooltip fy">
                <template solt="label">
                  <el-tooltip content="疲劳应力循环最小值" placement="top" effect="light">
                    <div>
                      SMIN
                    </div>
                  </el-tooltip>
                </template>
                <el-input v-model="form.user" placeholder=""></el-input>
              </el-form-item>
              <el-form-item label="" class="form-label-tooltip fy">
                <template solt="label">
                  <el-tooltip content="疲劳应力循环最大值" placement="top" effect="light">
                    <div>
                      SMAX
                    </div>
                  </el-tooltip>
                </template>
                <el-input v-model="form.user" placeholder=""></el-input>
              </el-form-item>
              <el-form-item label="" class="form-label-tooltip fy">
                <el-tooltip content="疲劳应力循环数" placement="top" effect="light">
                  <div>
                    N
                  </div>
                </el-tooltip>
                <el-input v-model="form.user" placeholder=""></el-input>
              </el-form-item> -->
            </el-form>
          </div>
          <div class="upload-file fyzh">
            <div>
              <!-- 文件列表 -->
              <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
                <li key="1123" class="el-upload-list__item ele-upload-list__item-content" style="border: none" v-for="(file, index) in fileList">
                  <span class="el-icon-document"> {{ file.name }} </span>
                </li>
              </transition-group>
            </div>
            <el-upload
              action="/"
              :before-upload="handleBeforeUpload"
              :file-list="fileList"
              :on-exceed="handleExceed"
              class="upload-file-uploader"
            >
                  <!-- :limit="limit" -->
              <!-- 上传按钮 -->
              <el-button size="mini" type="primary" style="width: 135px;">选择疲劳载荷谱文件</el-button>
              <!-- 上传提示 -->
              <div class="el-upload__tip" slot="tip" v-if="showTip">
                请上传
                <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
                <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
                的文件
              </div>
            </el-upload>
          </div>
          <div class="upload-file fyzh" v-if="form.ascm == 5 || form.ascm == '5' ">
            <div>
              <!-- 文件列表 -->
              <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
                <li key="1123" class="el-upload-list__item ele-upload-list__item-content" style="border: none" v-for="(file, index) in fileList2">
                  <span class="el-icon-document"> {{ file.name }} </span>
                </li>
              </transition-group>
            </div>
            <el-upload
              action="/"
              :before-upload="handleBeforeUpload2"
              :file-list="fileList2"
              :on-exceed="handleExceed2"
              class="upload-file-uploader"
            >
              <!-- 上传按钮 -->
              <el-button size="mini" type="primary" style="width: 135px;">选择模型参数文件</el-button>
              <!-- 上传提示 -->
              <div class="el-upload__tip" slot="tip" v-if="showTip">
                请上传
                <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
                <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
                的文件
              </div>
            </el-upload>
          </div>
        </div>
      </div>
    </div>
    <div class="line-warp"></div>
    <div class="container container-bottom">
      <div class="container-warp container-left" :style="{width:form.ascm == 5 ? '100%' : '49%'}">
        <div class="label-title">寿命预测</div>
        <div class="label-log-form" v-if="showResult == true">
          <el-form ref="form" label-width="160px" :inline="true" label-position="left">
            <el-form-item v-if="form.ascm != 5 ">
              <!-- <el-input v-model="form.user" placeholder="审批人"></el-input> -->
              <template solt="label" >
                <div class="label-subscript">
                  <el-tooltip content="结构疲劳累积损伤" placement="top" effect="light">
                    <div>
                      D<sub>L</sub>
                    </div>
                  </el-tooltip>
                </div>
              </template>
              {{dl}}
            </el-form-item>
            <el-form-item label="" v-if="form.ascm != 5">
              <!-- <el-input v-model="form.user" placeholder="审批人"></el-input> -->
              <template solt="label">
                <div class="label-subscript">
                  <el-tooltip content="结构疲劳寿命预测" placement="top" effect="light">
                    <div>
                      T<sub>S</sub>
                    </div>
                  </el-tooltip>
                </div>
              </template>
              {{ts}}
            </el-form-item>
            <el-form-item label="" v-if="form.ascm == 5">
              <!-- <el-input v-model="form.user" placeholder="审批人"></el-input> -->
              <template solt="label">
                <div class="label-subscript">
                  <el-tooltip content="年限" placement="top" effect="light">
                    <div>
                      n
                    </div>
                  </el-tooltip>
                </div>
              </template>
              {{n}}
            </el-form-item>
          </el-form>
        </div>
        <div  v-if="showResult == true" class="log-warp" :style="'height:'+logContentHeight+'px'">
          <div class="log-content divcontainer wrap-text" style="white-space:pre;width:10px">
            <span class="badge" @click="showLogModel">
              <img src="@/assets/images/big_X.png" style="width: 30px;height: 30px;">
              </span>
            {{ logText }}
          </div>
        </div>
        <!-- <el-button type="primary" class="detail-center-btn" >
          <svg-icon icon-class="user-list"/>
          打开日志文件
        </el-button> -->
      </div>
      <div class="container-warp container-right" :style="{display:form.ascm == 5 ? 'none' : 'block'}">
        <div class="label-title" style="margin-bottom: 10px">结构P-S-N图</div>
        <el-carousel  v-if="showSN == true" arrow="always" class="chart-warp" :style="'height:'+(logContentHeight+50)+'px'">
          <el-carousel-item v-for="item in 1" :key="item">
            <!-- <h3 class="small">{{ item }}</h3> -->
            <!-- {{ logContentHeight }} -->
            <sn-chart :chartData="loglineChartData"  ref="snchart"/>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
    <el-dialog
      width="80%"
      title="日志"
      :visible.sync="logModel"
      >
      <div class="wrap-text" :style="'height:'+ heightTestData +'px;overflow-y: auto;overflow-x: auto;white-space:pre'">
        {{ logText }}
      </div>
    </el-dialog>
    <el-dialog
      width="40%"
      title="计算温度系数"
      :visible.sync="wdModel"
      >
      <el-form ref="wform" class="dg-structure-form" :model="form" label-width="150px" :inline="true" label-position="left" :rules="wrules">
        <el-form-item  label=""  prop="wd">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="服役温度，℃" placement="top" effect="light">
                <div>
                  服役温度，℃
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.wd" placeholder="" type="number">
          </el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" class="detail-center-btn" @click="computeParamWD(form)">
        计算
      </el-button>
    </el-dialog>
    <el-dialog
      width="40%"
      title="计算设计系数"
      :visible.sync="dllModel"
      >
      <el-form ref="kform" class="dg-structure-form" :model="form" label-width="125px" :inline="true" label-position="left" :rules="krules">
        <el-form-item label=""  prop="gsigamma"  v-if="form.dlltype == 'PRESNWDLL' || form.dlltype == 'PRETNWDLL'">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="Gσ, 应力梯度" placement="top" effect="light">
                <div>
                  G<sub>a</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.gsigamma" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="rz"  v-if="form.dlltype == 'PRESNWDLL' || form.dlltype == 'PRETNWDLL'">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="表面粗糙度,μm" placement="top" effect="light">
                <div>
                  R<sub>z</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.rz" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="kt"  v-if="form.dlltype == 'PRESNWDLL' || form.dlltype == 'PRETNWDLL'">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="弹性应力集中系数" placement="top" effect="light">
                <div>
                  K<sub>t</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.kt" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="kv" >
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="表面处理系数" placement="top" effect="light">
                <div>
                  K<sub>v</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.kv" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="ks"  v-if="form.dlltype == 'PRESNWDLL' || form.dlltype == 'PRETNWDLL'">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="涂层系数" placement="top" effect="light">
                <div>
                  K<sub>s</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.ks" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="knle"  v-if="form.dlltype == 'PRESNWDLL' || form.dlltype == 'PRESWDLL'">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="KNL,E, 非线性应力应变系数" placement="top" effect="light">
                <div>
                  K<sub>nle</sub>（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.knle" placeholder="" type="number">
          </el-input>
        </el-form-item>
        <el-form-item label=""  prop="t"  v-if="form.dlltype == 'PRESWDLL' || form.dlltype == 'PRETWDLL' ">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="等效厚度，mm" placement="top" effect="light">
                <div>
                  t（>0）
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.t" placeholder="" type="number">
          </el-input>
        </el-form-item>

      </el-form>
      <el-button type="primary" class="detail-center-btn" @click="computeStructureParamDesign(form)">
        计算
      </el-button>
    </el-dialog>
  </div>
</template>

<script>
  import service from "@/api/material";
  import SnChart from "./snChart";
  export default {
    name: "Customdetail",
    components: {
      SnChart
    },
    props: {
      // 值
      value: [String, Object, Array],
      // 数量限制
      limit: {
        type: Number,
        default: 1,
      },
      // 大小限制(MB)
      fileSize: {
        type: Number,
        default: 5,
      },
      // 文件类型, 例如['png', 'jpg', 'jpeg']
      fileType: {
        type: Array,
        default: () => ["xlsx", "xls"],
      },
    },
    data() {
      return {
        elrules:{
          dlltype: [{
            required: true,
            message: '模块分类不能为空',
            trigger: 'change'
          }]
        },
        mrules:{
          rm: [{
            required: true,
            message: '材料标准试样的抗拉强度不能为空',
            trigger: 'blur'
          }],
          materialtype: [{
            required: true,
            message: '材料类别不能为空',
            trigger: 'change'
          }],
          m1: [{
            required: true,
            message: 'P-S-N第一段折线斜率负倒数不能为空',
            trigger: 'blur'
          }],
          m2: [{
            required: true,
            message: 'P-S-N第二段折线斜率负倒数不能为空',
            trigger: 'blur'
          }],
          nc: [{
            required: true,
            message: '特征疲劳寿命Cycle不能为空',
            trigger: 'blur'
          }],
          nd: [{
            required: true,
            message: '两折线段拐点对应疲劳寿命Cycle不能为空',
            trigger: 'blur'
          }],
          sc: [{
            required: true,
            message: '特征疲劳寿命对应疲劳强度幅值MPa',
            trigger: 'blur'
          }],
        },
        jrules:{
          ktd: [{
            required: true,
            message: '温度系数不能为空',
            trigger: 'blur'
          }],
          kwk: [{
            required: true,
            message: '设计系数不能为空',
            trigger: 'blur'
          }],
          dadmi: [{
            required: true,
            message: '损伤设计值不能为空',
            trigger: 'blur'
          }]
        },
        frules:{
          ascm: [{
            required: true,
            message: '平均应力修正方法不能为空',
            trigger: 'change'
          }],
          rst: [{
            required: true,
            message: '残余应力类型不能为空',
            trigger: 'change'
          }]
        },
        wrules:{
          wd: [{
            required: true,
            message: '服役温度不能为空',
            trigger: 'blur'
          }]
        },
        krules:{
          gsigamma: [{
            required: true,
            message: 'Gσ, 应力梯度不能为空',
            trigger: 'blur'
          }],
          rz: [{
            required: true,
            message: '表面粗糙度不能为空',
            trigger: 'blur'
          }],
          kt: [{
            required: true,
            message: '弹性应力集中系数不能为空',
            trigger: 'blur'
          }],
          kv: [{
            required: true,
            message: '表面处理系数不能为空',
            trigger: 'blur'
          }],
          ks: [{
            required: true,
            message: '涂层系数不能为空',
            trigger: 'blur'
          }],
          knle: [{
            required: true,
            message: ' KNL,E, 非线性应力应变系数不能为空',
            trigger: 'blur'
          }],
        },
        form:{
          dadmi : null
        },
        item: [1],
        logText: '',
        moduleClassSelectList: [
          {value: 'PRESNWDLL', label: '多方法正应力母材结构寿命预测',},
          {value: 'PRETNWDLL', label: '多方法切应力母材结构寿命预测',},
          {value: 'PRESWDLL', label: '多方法正应力焊接接头寿命预测',},
          {value: 'PRETWDLL', label: '多方法切应力焊接接头寿命预测',},
        ],
        IMSelectList: [
          {value: 1, label: '细晶结构钢',},
          {value: 2, label: '不锈钢',},
          {value: 3, label: '淬火钢',},
          {value: 4, label: '锻钢',},
          {value: 5, label: '其他钢',},
          {value: 6, label: '一般用途铸钢和热处理铸钢',},
          {value: 7, label: '球墨铸铁',},
          {value: 8, label: '可锻铸铁',},
          {value: 9, label: '片状石墨铸铁',},
          {value: 10, label: '挤压铝合金',},
          {value: 11, label: '变形铝合金',},
        ],
        correctionMethodSelectList: [
          {value: 1, label: 'FKM',},
          {value: 2, label: 'Goodman',},
          {value: 3, label: 'Geber',},
          {value: 4, label: 'Vonmiss-Hencky',},
          {value: 5, label: 'IMR',},
        ],
        SMINSelectList: [
          {value: 1, label: '高',},
          {value: 2, label: '中',},
          {value: 3, label: '小',},
        ],
        logModel: false,
        wdModel: false,
        dllModel: false,
        heightTestData: '',
        logContentHeight: '',
        number: 0,
        uploadList: [],
        fileList: [],
        fileList2: [],
        dl: '',
        ts: '',
        loglineChartData: {},
        showResult: false,
        showSN: false,
        selectedLabel : ""
      };
    },
    created() {
      this.logContentHeight = window.innerHeight - 570
    },
    watch: {
      value: {
        handler(val) {
          if (val) {
            let temp = 1;
            // 首先将值转为数组
            const list = Array.isArray(val) ? val : this.value.split(',');
            // 然后将数组转为对象数组
            this.fileList = list.map(item => {
              if (typeof item === "string") {
                item = { name: item, url: item };
              }
              item.uid = item.uid || new Date().getTime() + temp++;
              return item;
            });
          } else {
            this.fileList = [];
            return [];
          }
        },
        deep: true,
        immediate: true
      }
    },
    mounted() {
      this.$nextTick(()=>{
        this.heightTestData = window.innerHeight - 300
      })
      this.showResult = false
      this.showSN = false
    },
    methods: {
      listClass(index) {
      },
      goDetail(res) {
        this.$router.push({path: '/material/detail'})
      },
      showLogModel() {
        this.logModel = true
      },
      handleChange(value) {
        this.selectedLabel = this.moduleClassSelectList.find(option => option.value === value).label;
        this.form = {
          dadmi : null
        }
        this.$set(this.form, "dlltype", value)
        this.showResult = false
        this.showSN = false
        this.logText = null
        this.loglineChartData = {}
        this.ts = null
        this.dl = null
        this.fileList = []
        this.fileList2 = []
      },
      showWdModel() {
        if(this.form.materialtype==null || this.form.materialtype==undefined || this.form.materialtype==""){
          this.$modal.msgError(`材料类别IM不能为空!`);
          return false;
        }
        this.wdModel = true
      },
      showKwkModel() {
        if(this.form.dlltype==null || this.form.dlltype==undefined || this.form.dlltype==""){
          this.$modal.msgError(`模块分类不能为空!`);
          return false;
        }
        if(this.form.materialtype==null || this.form.materialtype==undefined || this.form.materialtype==""){
          this.$modal.msgError(`材料类别IM不能为空!`);
          return false;
        }
        if(this.form.dlltype == 'PRESNWDLL'  || this.form.dlltype == 'PRETNWDLL'){
          if(this.form.rm==null || this.form.rm==undefined || this.form.rm==""){
            this.$modal.msgError(`材料抗拉强度Rm不能为空!`);
            return false;
          }
        }else if(this.form.dlltype == 'PRESWDLL' || this.form.dlltype == 'PRETWDLL'){
          if(this.form.m1==null || this.form.m1==undefined || this.form.m1==""){
            this.$modal.msgError(`PSN第一折线段疲劳强度指数m1不能为空!`);
            return false;
          }
          if(this.form.nc==null || this.form.nc==undefined || this.form.nc==""){
            this.$modal.msgError(`特征疲劳寿命nc不能为空!`);
            return false;
          }
          if(this.form.nd==null || this.form.nd==undefined || this.form.nd==""){
            this.$modal.msgError(`PSN两折线段拐点对应疲劳寿命nd不能为空!`);
            return false;
          }
        }
        this.dllModel = true
      },
      countDadmi(form){
        if(this.form.materialtype==null || this.form.materialtype==undefined || this.form.materialtype==""){
          this.$modal.msgError(`材料类别IM不能为空!`);
          return false;
        }
        let formData = new FormData()
        formData.append('materialtype',form.materialtype)
        service.computeDesignParamDamage(formData).then(res => {
          this.form.dadmi = res.data.value
        }).catch((err)=>{
          if(err.code == 500){
            that.$modal.msgError(err.mas);
          }
        })

      },
      // 上传前校检格式和大小
      handleBeforeUpload(file) {
        // 校检文件类型
        if (this.fileType) {
          const fileName = file.name.split('.');
          const fileExt = fileName[fileName.length - 1];
          const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
          if (!isTypeOk) {
            this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
            return false;
          }
        }
        // 校检文件大小
        if (this.fileSize) {
          const isLt = file.size / 1024 / 1024 < this.fileSize;
          if (!isLt) {
            this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
            return false;
          }
        }
        // this.$modal.loading("正在上传文件，请稍候...");
        // this.number++;
        this.fileList = [file]
        return true;
      },
      // 上传前校检格式和大小
      handleBeforeUpload2(file) {
        // 校检文件类型
        if (this.fileType) {
          const fileName = file.name.split('.');
          const fileExt = fileName[fileName.length - 1];
          const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
          if (!isTypeOk) {
            this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
            return false;
          }
        }
        // 校检文件大小
        if (this.fileSize) {
          const isLt = file.size / 1024 / 1024 < this.fileSize;
          if (!isLt) {
            this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
            return false;
          }
        }
        // this.$modal.loading("正在上传文件，请稍候...");
        // this.number++;
        this.fileList2 = [file]
        return true;
      },
      // 文件个数超出
      handleExceed() {
        this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
      },
      // 获取文件名称
      getFileName(name) {
        // 如果是url那么取最后的名字 如果不是直接返回
        if (name.lastIndexOf("/") > -1) {
          return name.slice(name.lastIndexOf("/") + 1);
        } else {
          return name;
        }
      },
      // 对象转成指定字符串分隔
      listToString(list, separator) {
        let strs = "";
        separator = separator || ",";
        for (let i in list) {
          strs += list[i].url + separator;
        }
        return strs != '' ? strs.substr(0, strs.length - 1) : '';
      },
      computeParamWD(form){
        this.$refs.wform.validate(valid => {
          if (!valid) return
          let formData = new FormData()
          formData.append('wd',form.wd)
          formData.append('materialtype',form.materialtype)
          service.computeParamWD(formData).then(res => {
            this.$set(this.form, "ktd", res.data.value)
            this.wdModel = false
          }).catch((err)=>{
            if(err.code == 500){
              that.$modal.msgError(err.mas);
            }
          })
        })
      },
      computeStructureParamDesign(form){
        this.$refs.kform.validate(valid => {
          if (!valid) return
          let formData = new FormData()
          formData.append('dlltype',form.dlltype)
          formData.append('materialtype',form.materialtype)
          if(form.dlltype == 'PRESNWDLL'){
            formData.append('gsigamma',form.gsigamma)
            formData.append('rm',form.rm)
            formData.append('rz',form.rz)
            formData.append('kt',form.kt)
            formData.append('kv',form.kv)
            formData.append('ks',form.ks)
            formData.append('knle',form.knle)
          }else if(form.dlltype == 'PRESWDLL'){
            formData.append('m1',form.m1)
            formData.append('nc',form.nc)
            formData.append('nd',form.nd)
            formData.append('t',form.t)
            formData.append('kv',form.kv)
            formData.append('knle',form.knle)
          }else if(form.dlltype == 'PRETNWDLL'){
            formData.append('gsigamma',form.gsigamma)
            formData.append('rm',form.rm)
            formData.append('rz',form.rz)
            formData.append('kt',form.kt)
            formData.append('kv',form.kv)
            formData.append('ks',form.ks)
          }else if(form.dlltype == 'PRETWDLL'){
            formData.append('m1',form.m1)
            formData.append('nc',form.nc)
            formData.append('nd',form.nd)
            formData.append('t',form.t)
            formData.append('kv',form.kv)
          }
          service.computeStructureParamDesign(formData).then(res => {
            this.$set(this.form, "kwk", res.data.value)
            this.dllModel = false
          }).catch((err)=>{
            if(err.code == 500){
              that.$modal.msgError(err.mas);
            }
          })
        })
      },
      count(form){
        if(form.ascm == 5){
          this.$refs.elform.validate(valid => {
            if (!valid) return
            if(this.fileList.length==0){
              this.$modal.msgError(`请上传疲劳载荷谱文件!`);
              return false
            }
            if(this.fileList2.length==0){
              this.$modal.msgError(`请上传模型参数文件!`);
              return false
            }
            if(this.form.m2==null || this.form.m2==undefined || this.form.m2==""){
              this.$modal.msgError(`P-S-N第二段折线斜率负倒数m2不能为不能为空!`);
              return false;
            }
            if(this.form.m1==null || this.form.m1==undefined || this.form.m1==""){
              this.$modal.msgError(`P-S-N第一段折线斜率负倒数不能为m1不能为空!`);
              return false;
            }
            if(this.form.nc==null || this.form.nc==undefined || this.form.nc==""){
              this.$modal.msgError(`特征疲劳寿命nc不能为空!`);
              return false;
            }
            if(this.form.nd==null || this.form.nd==undefined || this.form.nd==""){
              this.$modal.msgError(`PSN两折线段拐点对应疲劳寿命nd不能为空!`);
              return false;
            }
             if(this.form.sc==null || this.form.sc==undefined || this.form.sc==""){
               this.$modal.msgError(`特征疲劳寿命对应疲劳强度幅值sc不能为空!`);
               return false;
             }
             if(this.form.ktd==null || this.form.ktd==undefined || this.form.ktd==""){
               this.$modal.msgError(`温度系数ktd不能为空!`);
               return false;
             }
             if(this.form.kwk==null || this.form.kwk==undefined || this.form.kwk==""){
               this.$modal.msgError(`温度系数kwk不能为空!`);
               return false;
             }
             if(this.form.c==null || this.form.c==undefined || this.form.c==""){
               this.$modal.msgError(`损伤设计值C不能为空!`);
               return false;
             }
             if(this.form.n==null || this.form.n==undefined || this.form.n==""){
               this.$modal.msgError(`载荷谱年限N不能为空!`);
               return false;
             }
            let file = this.fileList[0]
            let file2 = this.fileList2[0]
            let formData = new FormData()
            formData.append('file',file)
            formData.append('file2',file2)
            formData.append('c',form.c)
            formData.append('n',form.n)
            formData.append('dlltype',form.dlltype)
            formData.append('ascm',form.ascm)
            formData.append('m1',form.m1)
            formData.append('m2',form.m2)
            formData.append('nc',form.nc)
            formData.append('nd',form.nd)
            formData.append('sc',form.sc)
            formData.append('kwk',form.kwk)
            formData.append('ktd',form.ktd)
            service.customModuleForecast(formData).then(res => {
              this.showResult = true
              this.showSN = false
              this.logText = res.data.contents
              this.n = res.data.n.toExponential()
              // this.loglineChartData.title = this.selectedLabel + "SN图"
              // if(res.data.ymin == undefined){
              //   res.data.ymin = 1.00E-100
              // }
              // this.loglineChartData.ymin = res.data.ymin
              // this.loglineChartData.xmin = res.data.xmin
              // this.loglineChartData.ymax = res.data.ymax
              // this.loglineChartData.xmax = res.data.xmax
              // this.loglineChartData.data = res.data.data
              console.log(this.loglineChartData)
              this.$nextTick(() => {
                this.$refs.snchart[0].initChart()
              });
            }).catch((err)=>{
              if(err.code == 500){
                that.$modal.msgError(err.mas);
              }

            })
          })
        }else{
          this.$refs.elform.validate(valid => {
            if (!valid) return
            this.$refs.mform.validate(valid2 => {
              if (!valid2) return
              this.$refs.jform.validate(valid3 => {
                if (!valid3) return
                this.$refs.fform.validate(valid3 => {
                  if (!valid3) return
                  console.log(form)
                  console.log(this.$refs)
                  if(this.fileList.length==0){
                    this.$modal.msgError(`请上传服役载荷文件!`);
                    return false
                  }
                  let file = this.fileList[0]
                  let formData = new FormData()
                  formData.append('file',file)
                  formData.append('dlltype',form.dlltype)
                  formData.append('materialtype',form.materialtype)
                  formData.append('rm',form.rm)
                  formData.append('m1',form.m1)
                  formData.append('m2',form.m2)
                  formData.append('nc',form.nc)
                  formData.append('nd',form.nd)
                  formData.append('sc',form.sc)
                  formData.append('kwk',form.kwk)
                  formData.append('ktd',form.ktd)
                  formData.append('dadmi',form.dadmi)
                  formData.append('ascm',form.ascm)
                  formData.append('rst',form.rst)
                  service.customModuleForecast(formData).then(res => {
                    this.showResult = true
                    this.showSN = true
                    this.logText = res.data.contents
                    this.loglineChartData.title = this.selectedLabel + "SN图"
                    this.loglineChartData.ymin = res.data.ymin
                    this.loglineChartData.xmin = res.data.xmin
                    this.loglineChartData.ymax = res.data.ymax
                    this.loglineChartData.xmax = res.data.xmax
                    this.loglineChartData.data = res.data.data
                    this.ts = res.data.ts.toExponential()
                    this.dl = res.data.dl.toExponential()
                    this.$nextTick(() => {
                      this.$refs.snchart[0].initChart()
                    });
                  }).catch((err)=>{
                    if(err.code == 500){
                      that.$modal.msgError(err.mas);
                    }

                  })
                })
              })
            })
          })
        }

      }
    }
  };
</script>

<style scoped lang="scss">
  .app-container {
    display: block;
    padding: 5px;
    height: calc(100% - 65px);
  }
  .container-bottom{
    height: calc(100% - 295px);
    overflow: auto;
  }

  .detail-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    font-size: 20px;

    &:before, &:after {
      content: '';
      display: inline-block;
      width: 37%;
      height: 4px;
      border-bottom: 1px solid #BAD7EC;
      border-top: 1px solid #BAD7EC;
    }
  }

  .detail-title-form {
    width: 450px;
    margin: 10px auto;
    ::v-deep .el-form-item{
      margin-bottom: 15px;
    }
    ::v-deep .el-form-item__label {
      color: #084EBC;
      font-weight: normal;
    }
  }

  .container {
    width: 100%;
    display: flex;
    justify-content: space-around;
  }

  .container-warp {
    width: 100%;
    display: inline-block;
    border: 1px solid #ddd;
    background-color: #fff;
    box-shadow: 0 0 5px #eeeeee;
  }

  .container-right {
    .container-warp + .container-warp {
      margin-top: 10px;
    }
  }

  .container-left {
    width: 49%;
  }

  .container-right {
    width: 49%;
  }

  .detail-center-btn {
    display: block;
    width: 260px;
    margin: 6px auto;
  }

  .table-title {
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    height: 26px;
    color: #5184ec;
    text-indent: 10px;
    border-bottom: 1px solid #d5d5d5;
    background: url("../../../assets/images/line.png") no-repeat;
    background-position: -143px 22px;
  }

  .material-pic {
    background-color: #fff;
    border: 1px solid #CCDCE7;
    border-radius: 5px;
    width: 100%;
    max-width: 330px;
    height: 190px;
    margin-top: 15px;
    margin-left: 5px;
    display: flex;
    align-items: center;
    justify-content: center;

    img {
      width: 209.28px;
      height: 173.6px;
    }
  }

  .material-form {
    margin-top: 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 46%;
      margin-bottom: 12px;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 70px);
    }

    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 70px) !important;
    }
  }

  .label-title {
    width: 133px;
    font-size: 14px;
    font-weight: 400;
    line-height: 24px;
    height: 26px;
    color: #5184ec;
    text-indent: 10px;
    border-left: 3px solid #166BCE;
    background: url("../../../assets/images/label_bg.png") no-repeat;
    background-size: 100%;
  }


  .log-warp {
    width: 96%;
    margin-left: 2%;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: auto;
    padding: 5px 10px;
    height: 100%;
    font-size: 14px;
  }

  .label-log-form {
    margin-top: 5px;
    text-align: center;
  }

  .log-warp + .detail-center-btn {
    width: 300px;
  }

  .label-subscript {
    display: inline-block;
    width: 70px;
  }

  .structure-form {
    .label-subscript {
      width: 90px;
    }
  }

  .structure-form {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 31%;
      margin-bottom: 0px !important;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 90px);
      margin-bottom: 0px !important;
    }

    ::v-deep .el-input-group__append {
      padding: 0 6px;
    }
  }

  .structure-forms {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 48%;
      margin-bottom: 4px !important;
    }

    ::v-deep .fy {
      width: 31%;
    }

    /*::v-deep .fy .el-tooltip {*/
    /*  width: 90px !important;*/
    /*}*/

    /*::v-deep .fy .el-input--medium {*/
    /*  width: calc(100% - 90px)  !important;*/
    /*}*/

    ::v-deep .el-form-item__content {
      width: calc(100% - 125px);
    }

    .form-label-tooltip {
      ::v-deep .el-form-item__content {
        width: 100%;
      }

      ::v-deep .el-tooltip {
        width: 50px;
        display: inline-block;
      }

      ::v-deep .el-input--medium {
        width: calc(100% - 50px);
      }
    }
  }
  .divcontainer {
    position: relative;
  }

  .badge {
    position: absolute;
    cursor: pointer;
    top: -5px;
    right: -10px;
    width: 30px;
    height: 30px;
    background-color: #ffffff;
    color: white;
    /* border-radius: 50%; */
    text-align: center;
    line-height: 30px;
  }
  .chart-warp{
    .el-carousel__item{
      width: 80%;
      margin-left: 10%;
    }
  }
  .line-warp{
    width: 98%;
    height: 4px;
    border-top: 1px dashed #bad7ec;
    border-bottom: 1px dashed #bad7ec;
    margin: 6px 1%;
  }
  ::v-deep .el-carousel__container{
    height: 100%;
  }
  .upload-file-uploader {
    margin-bottom: 0px;
    margin-left: auto;
    margin-right: auto;
  }
  .upload-file-list .el-upload-list__item {
    border: 1px solid #e4e7ed;
    line-height: 2;
    margin-bottom: 10px;
    position: relative;
  }
  .upload-file-list .ele-upload-list__item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: inherit;
  }
  .ele-upload-list__item-content-action .el-link {
    margin-right: 10px;
  }
  .fyzh{
    display: inline-flex;
    width: 100%;
  }
  /* CSS 类用于换行 */
  .wrap-text {
    white-space: pre-line;
  }

  /* 用于处理长单词或 URL 的换行 */
  .break-word {
    word-break: break-all;
    overflow-wrap: break-word;
  }

  ::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before{
      // content: '*' !important;
      display: none
  }
  .dg-label-subscript {
    display: inline-block;
    width: 100px;
  }
  .dg-structure-form {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 46%;
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 100px);
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input-group__append {
      padding: 0 6px;
    }
    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 100px) !important;
    }
  }

  ::v-deep .el-upload-list__item-name{
    display: none !important;
  }

</style>
